home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK2.toast / Development Kits (Disc 2) / QuickDraw GX / Programming Stuff / Sample Code / Printing Samples / Printer Drivers… / ImageWriter--Chooser snooper / OldApp.c < prev    next >
Encoding:
Text File  |  1995-04-10  |  18.1 KB  |  662 lines  |  [TEXT/MPS ]

  1. /*
  2.     copyright © 1992-1994 Apple Computer Inc.  All rights reserved.
  3.     
  4.     OldApp.c
  5.     This file implements old application message overrides for the specific driver.
  6.     
  7.     Included in this file is the old PrintRecord emulation.  Note that the ImageWriter
  8.     PrintRecord is a wonder of misdirection and special cases.  You'll have fun
  9.     figuring out the code - so unless you really want to exactly emulate the ImageWriter
  10.     pages, you shouldn't spend too much time looking at this code.
  11.     
  12.     Modification history
  13.     7/23/92            TED                New file today
  14.     12/20/93        dmh                Sync'd with the shipping 1.0b3 GX driver.
  15.      8/26/94        dmh                Sync'd with the shipping 1.0.1 GX driver.
  16.  
  17. */
  18.  
  19. // Include the standard Mac header files 
  20. #include <Errors.h>
  21. #include <ToolUtils.h>
  22. #include <StdIO.h>
  23. #include <StdLib.h>
  24. #include <String.h>
  25. #include <Strings.h>
  26. #include <Resources.h>
  27. #include <ToolUtils.h>
  28. #include <OSUtils.h>
  29. #include <Files.h>
  30. #include <Types.h>
  31. #include <Packages.h>
  32. #include <Memory.h>
  33. #include <Serial.h>
  34. #include <Devices.h>
  35. #include <Fonts.h>
  36. #include <Printing.h>
  37. #include <Script.h>
  38. #include <Events.h>
  39. #include <Dialogs.h>
  40. #include <FixMath.h>
  41. #include <Lists.h>
  42. #include <AppleTalk.h>
  43. #include <Menus.h>
  44. #include <Events.h>
  45. #include <Balloons.h>
  46. #include <Folders.h>
  47. #include <SCSI.h>
  48.  
  49. // Include the new QuickDraw GX graphics header files 
  50. #include <graphics routines.h>
  51. #include <graphics libraries.h>
  52. #include <math routines.h>
  53. #include <qd library.h>
  54. #include <font library.h>
  55. #include <layout routines.h>
  56. #include <graphics libraries.h>
  57.  
  58. // Include the required Printing Manager header files 
  59. #include <PrintingManager.h>
  60. #include <PrintingMessages.h>
  61. #include <PrintingDrivers.h>
  62. #include <Collections.h>
  63. #include <Messages.h>
  64. #include <PrintingResTypes.h>
  65. #include <PrintingErrors.h>
  66. #include <PrintingLibraries.h>
  67.  
  68. #include <GXExceptions.h>
  69.  
  70. #include "CommonDefines.h"            // things common to .r and .h files
  71.  
  72. /* ----------------------------------------------------------------------------    */
  73. /* INTERNAL TYPEDEFS AND STRUCTURES                                                */
  74. /* ----------------------------------------------------------------------------    */
  75. // ImageWriter wDev values
  76. #define kBest            0x01
  77. #define kPortrait        0x02
  78. #define kTallAdjusted    0x04
  79. #define k50Percent        0x08
  80. #define kNoGaps            0x10
  81. #define kSetResCalled    0x20
  82.  
  83. // some ImageWriter constants
  84. #define kGapSize        60        // gap at top of page in 120ths of an inch
  85. #define kSmallPlaten    16        // platen width in half inches for small IW
  86. #define kBigPlaten        27        // platen width in half inches for the 15" IW
  87.  
  88. /* ----------------------------------------------------------------------------    */
  89. /* FORWARD DECLARES                                                                */
  90. /* ----------------------------------------------------------------------------    */
  91. OSErr SD_ConvertPrintRecordTo(THPrint hoPrint);
  92. OSErr SD_ConvertPrintRecordFrom(gxUniversalPrintRecordHdl huPrint);
  93.  
  94.  
  95. /* ----------------------------------------------------------------------------    */
  96. /* INTERNAL ROUTINES                                                            */
  97. /* ----------------------------------------------------------------------------    */
  98. OSErr    UpdatePrintRecord(THPrint hPrint)
  99. {
  100.     OSErr                        anErr;
  101.     gxUniversalPrintRecordHdl     huPrint = hPrint;
  102.     gxUniversalPrintRecordPtr     puPrint;
  103.     short                        devVRes, devHRes, appVRes, appHRes;
  104.     short                        cPlaten;
  105.     
  106.     // convert to universal format
  107.     anErr = SD_ConvertPrintRecordTo(hPrint);
  108.     if (anErr == noErr)
  109.         {
  110.         // determine application & device resolutions, based upon quality mode, tall adjusted
  111.         // setting, and if the app called SetRsl:
  112.         //    draft - 80(h)*72(v)
  113.         //    faster - 80(h)*72(v)
  114.         //    best - 160(h)*144(v)
  115.         //
  116.         //    draft (tall adjusted) - 72*72
  117.         //    faster (tall adjusted) - 72*72
  118.         //    best (tall adjusted) - 144*144
  119.         
  120.         puPrint = *huPrint;
  121.         if (puPrint->options & gxPreciseBitmap)
  122.             switch(puPrint->qualityMode)
  123.                 {
  124.                 case gxDraftQuality:
  125.                 case gxFasterQuality:
  126.                     devVRes = devHRes = 72;
  127.                     appVRes = appHRes = 72;
  128.                     break;
  129.                     
  130.                 case gxBestQuality:
  131.                     devVRes = devHRes = 144;
  132.                     appVRes = appHRes = 72;
  133.                     break;
  134.                 }
  135.         else
  136.             switch(puPrint->qualityMode)
  137.                 {
  138.                 case gxDraftQuality:
  139.                 case gxFasterQuality:
  140.                     appVRes = devVRes = 72;
  141.                     appHRes = devHRes = 80;
  142.                     break;
  143.                     
  144.                 case gxBestQuality:
  145.                     devVRes = 144;
  146.                     devHRes = 160;
  147.                     appVRes = 72;
  148.                     appHRes = 80;
  149.                     break;
  150.                 }
  151.             
  152.         // SetRsl was called?  Use the resolution specified by the application
  153.         if (puPrint->appVRes != 72)
  154.             {
  155.             appVRes = devVRes = puPrint->appVRes;
  156.             appHRes = devHRes = puPrint->appHRes;
  157.             }
  158.             
  159.         // finally, store the app & device resolutions
  160.         puPrint->devVRes = devVRes;
  161.         puPrint->devHRes = devHRes;
  162.         puPrint->appVRes = appVRes;
  163.         puPrint->appHRes = appHRes;
  164.         
  165.         // here we do page size calculations
  166.         // Please note that this code is confusing - it's purpose is to emulate
  167.         // the existing ImageWriter driver's page size.  Most drivers would not
  168.         // do this - the existing in the system probably is good enough.
  169.         {
  170.         long        pageGap;                // gap at top of page
  171.         long        dvPaper, dhPaper;        // paper size at device res
  172.         long        dvPage, dhPage;            // page size at device res
  173.         long        scanLines, scanBits;    // # of scan lines or bits on page
  174.         long        maxH;                    // maximum width
  175.         long        hOff, vOff;                // margins (horiz & vert) to get paper rect from page rect
  176.         
  177.         // gap at the top of the page in pixels
  178.         pageGap = (kGapSize * appVRes) / 120;
  179.         if (puPrint->options & gxBiggerPages)
  180.             pageGap = 0;
  181.             
  182.         // figure out paper size in application space pixels
  183.         dvPaper = (puPrint->pageV * appVRes) / 120;
  184.         dhPaper = (puPrint->pageH * appHRes) / 120;
  185.                 
  186.         // vertically, align to the head height of 8 pixels
  187.         scanLines = ((dvPaper - pageGap) >> 3) << 3;
  188.         
  189.         // horizontally, allow the biggest width we can handle
  190.         cPlaten = kSmallPlaten;
  191.         if (puPrint->pageH > (9*120) )
  192.             cPlaten = kBigPlaten;
  193.             
  194.         maxH = (cPlaten * appHRes) >> 1;
  195.         if (maxH > dhPaper)
  196.             maxH = dhPaper;
  197.         scanBits = (maxH >> 4) << 4;
  198.         
  199.         if (puPrint->orientation == gxPortraitOrientation)
  200.             {
  201.             // portrait
  202.             
  203.             dhPage = scanBits;
  204.             dvPage = scanLines;
  205.             
  206.             hOff = (dhPage - dhPaper) >> 1;
  207.             vOff = -pageGap;
  208.             }
  209.         else
  210.             {
  211.             // landscape
  212.             
  213.             dhPage = scanLines;
  214.             dvPage = scanBits;
  215.             
  216.             // reverse the paper definition as well
  217.             {
  218.             long iTemp = dhPaper;
  219.             dhPaper = dvPaper;
  220.             dvPaper = iTemp;
  221.             }
  222.             
  223.             hOff = -pageGap;
  224.             vOff = (dvPage - dvPaper) >> 1;
  225.             }
  226.             
  227.         // 50% reduction?  scale everything by 2X
  228.         if (puPrint->options & gxUserFlag0)
  229.             {
  230.             dhPage <<= 1;
  231.             dvPage <<= 1;
  232.             dhPaper <<= 1;
  233.             dvPaper <<= 1;
  234.             hOff <<= 1;
  235.             vOff <<= 1;
  236.             }
  237.             
  238.         // set the page and paper in app space
  239.         puPrint->appPage.left         = puPrint->appPage.top = 0;
  240.         puPrint->appPage.right         = dhPage;
  241.         puPrint->appPage.bottom     = dvPage;
  242.         
  243.         puPrint->appPaper.left         = hOff;
  244.         puPrint->appPaper.top         = vOff;
  245.         puPrint->appPaper.right     = dhPaper + hOff;
  246.         puPrint->appPaper.bottom     = dvPaper + vOff;
  247.                 
  248.         // from page, scale up to device space (in case some weenie decides to look at that)
  249.         puPrint->devPage.left         = puPrint->devPage.top = 0;
  250.         puPrint->devPage.right         = dhPage * devHRes / appHRes;
  251.         puPrint->devPage.bottom     = dvPage * devVRes / appVRes;
  252.         }
  253.         
  254.         // convert back to non-universal format
  255.         anErr = SD_ConvertPrintRecordFrom((gxUniversalPrintRecordHdl) hPrint);
  256.         }
  257.         
  258.     return(anErr);
  259.     
  260. } // UpdatePrintRecord
  261.  
  262. //<FF>
  263. /* ----------------------------------------------------------------------------    */
  264. /* MESSAGE OVERRIDES                                                            */
  265. /* ----------------------------------------------------------------------------    */
  266. OSErr SD_ConvertPrintRecordTo(THPrint hoPrint)
  267. /*
  268.     This call takes a print record in old style (driver specific) format, and
  269.     converts it to the format of "gxUniversalPrintRecordHdl"
  270. */
  271. {
  272.     TPPrint                        poPrint;            // pointer to old style print record
  273.     gxUniversalPrintRecordHdl    huPrint = hoPrint;    // handle to universal print record
  274.     gxUniversalPrintRecordPtr    puPrint;            // pointer to universal print record
  275.     short                        qualityMode;        // cached quality mode
  276.     short                        wDev;                // cached wDev
  277.     
  278.     // cache pointers for size and speed
  279.     puPrint = *huPrint;
  280.     poPrint = *hoPrint;
  281.     wDev = poPrint->prStl.wDev;
  282.     
  283.     // determine quality mode
  284.     if (poPrint->prJob.bJDocLoop == 0)
  285.         qualityMode = gxDraftQuality;
  286.     else
  287.         {
  288.         if (wDev & kBest)
  289.             qualityMode = gxBestQuality;
  290.         else
  291.             qualityMode = gxFasterQuality;
  292.         }
  293.         
  294.     // universal feed is the inverse of our feed
  295.     puPrint->feed            =    1-(poPrint->prStl.feed);
  296.     
  297.     // wDev 0x02 means portrait, else landscape
  298.     if (wDev & kPortrait) 
  299.         puPrint->orientation    =    gxPortraitOrientation;
  300.     else
  301.         {
  302.         puPrint->orientation    =    gxLandscapeOrientation;
  303.         
  304.         // landscape disabled draft, forces tall adjusted
  305.         if (qualityMode == gxDraftQuality)
  306.             qualityMode = gxFasterQuality;
  307.         wDev |= kTallAdjusted;
  308.         }
  309.         
  310.     // copies are in iCopies field (wow.)
  311.     puPrint->actualCopies        =    poPrint->prJob.iCopies;
  312.     
  313.     // store our flags
  314.     puPrint->options = 0;
  315.     
  316.     // tall adjusted
  317.     if (wDev & kTallAdjusted) 
  318.         puPrint->options |= gxPreciseBitmap;
  319.         
  320.     // 50% reduction
  321.     if (wDev & k50Percent) 
  322.         {
  323.         puPrint->options |= gxUserFlag0;
  324.         puPrint->reduction = 50;
  325.         
  326.         // for 50% reduction, we always return faster to the application
  327.         qualityMode = gxFasterQuality;
  328.         }
  329.     else
  330.         puPrint->reduction = 100;
  331.         
  332.     // no gaps
  333.     if (wDev & kNoGaps) 
  334.         puPrint->options |= gxBiggerPages;
  335.     
  336.     // finally, store quality mode    
  337.     puPrint->qualityMode = qualityMode;
  338.     
  339.     // and we can't have any errors - because this code is too godlike.
  340.     return(noErr);
  341.     
  342. } // SD_ConvertPrintRecordTo
  343.  
  344. //<FF>
  345. /* ----------------------------------------------------------------------------    */
  346. OSErr SD_ConvertPrintRecordFrom(gxUniversalPrintRecordHdl huPrint)
  347. /*
  348.     This call takes a print record in universal format and converts it
  349.     to old style (driver specific) format.
  350.     
  351.     Note: for the ImageWriter, I'm filling in way more things than theoretically
  352.     I need to.  However, since the ImageWriter is one of the oldest print drivers,
  353.     there is much more of a chance that someone assumes something about one or
  354.     more of the fields.
  355. */
  356. {
  357.     gxUniversalPrintRecordPtr    puPrint;            // pointer to universal print record
  358.     THPrint                        hoPrint = huPrint;    // handle to old style print record
  359.     TPPrint                        poPrint;            // pointer to old style print record
  360.     short                        options;            // cached universal options
  361.     short                        qualityMode;        // cached universal quality mode
  362.     short                        actualCopies;        // cached universal copies
  363.     
  364.     // cache pointers for size and speed
  365.     puPrint = *huPrint;
  366.     poPrint = *hoPrint;
  367.  
  368.     // save away fields within the universal record that we'll be stomping over
  369.     // as we convert
  370.     options         = puPrint->options;
  371.     qualityMode     = puPrint->qualityMode;
  372.     actualCopies    = puPrint->actualCopies;
  373.     
  374.     poPrint->iPrVersion            = 4;        // used to be 3, but this is
  375.                                             // a new driver.  We support versions
  376.                                             // 3 and 4
  377.     poPrint->prInfo.iDev        = 0;        // always zero for the ImageWriter
  378.     
  379.     // skip remaining fields in prInfo because they are unchanged
  380.     
  381.     // determine the wDev
  382.     {
  383.     short    wDev;
  384.     
  385.     // this is the wDev value for the ImageWriter
  386.     wDev = 0x0100;
  387.     
  388.     if (puPrint->orientation == gxPortraitOrientation)
  389.         wDev |= kPortrait;
  390.     else
  391.         {
  392.         // for landscape, disable draft and force tall adjusted
  393.         if (qualityMode == gxDraftQuality)
  394.             qualityMode = gxFasterQuality;
  395.             
  396.         options |= gxPreciseBitmap;
  397.         }
  398.     
  399.     // user options
  400.     if (options & gxPreciseBitmap)
  401.         wDev |= kTallAdjusted;
  402.     if (options & gxUserFlag0)
  403.         {
  404.         wDev |= k50Percent;
  405.         qualityMode = gxFasterQuality;
  406.         }
  407.  
  408.     if (options & gxBiggerPages)
  409.         wDev |= kNoGaps;
  410.         
  411.     // if the application's resolution isn't 72 - then clearly SetRsl must have been called
  412.     // to change it.
  413.     if (poPrint->prInfo.iVRes != 72)
  414.         {
  415.         wDev |= kSetResCalled;
  416.         qualityMode == gxBestQuality;
  417.         }
  418.         
  419.     if (qualityMode == gxBestQuality)
  420.         wDev |= kBest;
  421.         
  422.         
  423.     // and finally, save away that short value we worked so hard to determine
  424.     poPrint->prStl.wDev = wDev;
  425.     }
  426.  
  427.     // other fields in prStl remain the same
  428.     
  429.     poPrint->prStl.bPort     = 0;
  430.     poPrint->prStl.feed     = 1 - (puPrint->feed);
  431.     poPrint->prInfoPT.iDev     = (qualityMode == gxBestQuality) ? -768 : 0;
  432.  
  433.     // other fields in prInfoPT remain the same
  434.     {
  435.     Rect    rPage = poPrint->prInfoPT.rPage;
  436.     
  437.     // calculate some fields we don't use - in case someone really wants to look at
  438.     // them for some reason
  439.     poPrint->prXInfo.iRowBytes    = rPage.right >> 3;
  440.     poPrint->prXInfo.iBandV        = 32;
  441.     poPrint->prXInfo.iBandH        = poPrint->prXInfo.iRowBytes << 3;
  442.     poPrint->prXInfo.iDevBytes    = poPrint->prXInfo.iRowBytes * 
  443.                                     poPrint->prXInfo.iBandV + 
  444.                                     poPrint->prXInfo.iBandH;
  445.     poPrint->prXInfo.iBands        = (rPage.bottom+(poPrint->prXInfo.iBandV-1)) / poPrint->prXInfo.iBandV;
  446.     poPrint->prXInfo.bPatScale     = (qualityMode == gxBestQuality) ? -2 : 0;
  447.     poPrint->prXInfo.bUlThick     = 1;
  448.     poPrint->prXInfo.bUlOffset     = 1;
  449.     poPrint->prXInfo.bUlShadow     = 1;
  450.     poPrint->prXInfo.scan        = (poPrint->prStl.wDev & kPortrait) ? 0 : 2;
  451.     poPrint->prXInfo.bXInfoX    = 0;
  452.     }
  453.     
  454.     // other fields in prJob remain the same
  455.     poPrint->prJob.iCopies        = actualCopies;
  456.     poPrint->prJob.bJDocLoop    = (qualityMode == gxDraftQuality) ? 0 : 1;
  457.     
  458.     // this routine is so studly, there can be no errors
  459.     return(noErr);    
  460.     
  461. } // SD_ConvertPrintRecordFrom
  462.  
  463.  
  464. //<FF>
  465. /* ----------------------------------------------------------------------------    */
  466. OSErr SD_PrintRecordToJob(THPrint hPrint, gxJob theJob)
  467. /*
  468.     We convert the "tall adjusted" setting into the correct rendering option for
  469.     the job collection.
  470. */
  471. {
  472.     OSErr    anErr;
  473.     Handle     jobQualitySettingsHdl;    
  474.     
  475.     anErr = Forward_GXPrintRecordToJob(hPrint, theJob);
  476.     if (anErr == noErr)
  477.         {
  478.         long imagewriterOptions = kSuperRes;
  479.         
  480.         if ((**hPrint).prStl.wDev & kSetResCalled)
  481.             {
  482.             Collection            jobCollection = GXGetJobCollection(GXGetJob());
  483.             gxQualityInfo        *qualitySettings;
  484.     
  485.  
  486.             // get old info and replace it with final quality
  487.  
  488.  
  489.             jobQualitySettingsHdl = NewHandle(0);
  490.             anErr = MemError();
  491.             nrequire(anErr, FailedNewHandle);
  492.  
  493.             anErr = GetCollectionItemHdl (     jobCollection,
  494.                                                 gxQualityTag,
  495.                                                  gxPrintingTagID,
  496.                                                jobQualitySettingsHdl );
  497.  
  498.             if (anErr == collectionItemNotFoundErr) 
  499.                 {
  500.                 Str255            bestString, roughString;
  501.                 Size            count1, count2;
  502.                 Ptr                p;
  503.                 short            curResFile = CurResFile();
  504.                 
  505.                 UseResFile(GXGetMessageHandlerResFile());
  506.                 GetIndString( bestString, kOldQualityID, kBestString);
  507.                 GetIndString( roughString, kOldQualityID, kRoughString);
  508.                 UseResFile(curResFile);
  509.  
  510.                 SetHandleSize(jobQualitySettingsHdl,(sizeof(gxQualityInfo) + bestString[0] + roughString[0] + 2 ));
  511.                 anErr = MemError();
  512.                 nrequire( anErr, FailedSetHandleSize );
  513.                         
  514.                 qualitySettings = *((gxQualityInfo **) jobQualitySettingsHdl);
  515.                 
  516.                 qualitySettings->disableQuality = false;
  517.                 qualitySettings->defaultQuality = 1;
  518.                 qualitySettings->currentQuality = 1;
  519.                 qualitySettings->qualityCount = 2;
  520.         
  521.                 count1 = bestString[0]+1;
  522.                 p = qualitySettings->qualityNames;
  523.                 BlockMove( bestString, p, count1 );
  524.         
  525.                 count2 = roughString[0]+1;
  526.                 p += count1;
  527.                 BlockMove( roughString, p, count2 );
  528.         
  529.                 }
  530.             else
  531.                 qualitySettings = *((gxQualityInfo **) jobQualitySettingsHdl);
  532.  
  533.             (qualitySettings->currentQuality = qualitySettings->qualityCount-1);
  534.  
  535.             anErr = AddCollectionItemHdl (     jobCollection,
  536.                                             gxQualityTag,
  537.                                             gxPrintingTagID,
  538.                                             jobQualitySettingsHdl );
  539.                                                  
  540.             if (anErr == noErr)
  541.                 (void) SetCollectionItemInfo(jobCollection, gxQualityTag, gxPrintingTagID, 0x0000FFFF, gxVolatileOutputDriverCategory);
  542.                 
  543.             DisposHandle(jobQualitySettingsHdl);
  544.             }
  545.  
  546.         if ((**hPrint).prStl.wDev & kTallAdjusted)
  547.             imagewriterOptions = 0;
  548.             
  549.         if (anErr == noErr)
  550.             anErr = AddCollectionItem(GXGetJobCollection(theJob), 
  551.                         DriverCreator,
  552.                         0,
  553.                         sizeof(imagewriterOptions),
  554.                         &imagewriterOptions);
  555.         }
  556.  
  557. FailedNewHandle:        
  558.     return(anErr);
  559.  
  560. FailedSetHandleSize:
  561.     DisposHandle(jobQualitySettingsHdl);
  562.     return(anErr);
  563.     
  564. } // SD_PrintRecordToJob
  565.  
  566. //<FF>
  567. /* ----------------------------------------------------------------------------    */
  568. OSErr SD_PrValidate(    THPrint hPrint,                 // old style print record
  569.                         Boolean *wasChanged)            // was the print record changed?
  570. /*
  571.     This call validates the current print record.  It's fairly simplistic (as were
  572.     all of the old drivers) - the wDev or versions don't match the current, we call
  573.     PrintDefault.  Otherwise, we call UpdatePrintRecord - to allow the driver to sanity
  574.     check any internal fields.
  575.     
  576. */
  577. {
  578.     unsigned short    wDev;                        // note: if this were signed, the shift below would fail                    
  579.     Boolean            recordIsInvalid = true;            
  580.     OSErr            anErr = noErr;
  581.     
  582.     // check the wDev.  The upper byte must be equal to our idea of the wDev
  583.         
  584.     wDev =  (**hPrint).prStl.wDev;    
  585.     wDev >>= 8;                                // get just the device ID
  586.  
  587.     // If the device id is equal, then check the version number of the print record.
  588.     //    Only if that is also equal to the current version, will we return false (valid).
  589.         
  590.     if (     (wDev == 1) 
  591.         &&
  592.             (
  593.             ( ((**hPrint).iPrVersion) == 3 ) ||
  594.             ( ((**hPrint).iPrVersion) == 4 ) 
  595.             )
  596.         )
  597.         recordIsInvalid = false;
  598.             
  599.  
  600.     // If the the print record is not valid, then return the default print record.
  601.     // Otherwise, update the print record, based on the application's calls
  602.     // to PrGeneral.
  603.         
  604.     if (recordIsInvalid)
  605.         PrintDefault(hPrint);
  606.     else
  607.         anErr = UpdatePrintRecord(hPrint);
  608.         
  609.     *wasChanged = recordIsInvalid;
  610.     
  611.     return (anErr);
  612.     
  613. } // SD_PrValidate
  614.  
  615. //<FF>
  616. /* ----------------------------------------------------------------------------    */
  617. OSErr SD_PrJobInit(THPrint hPrint, TPPrDlg * pDlg)
  618. /*
  619.     This routine is called to initialize the job dialog.  We take the default
  620.     behavior - and then disable some of the items based on settings the user
  621.     has made:
  622.         - 50% disables all items
  623.         - apps that call SetRsl disable all items
  624.         - landscape disables draft mode
  625. */
  626. {
  627.     OSErr    anErr;
  628.     
  629.     anErr = Forward_GXPrJobInit(hPrint, pDlg);
  630.     if (anErr == noErr)
  631.         {
  632.         Boolean    disableDraft     = false;
  633.         Boolean    disableAll         = false;
  634.         short    wDev             = (**hPrint).prStl.wDev;
  635.         short    idx;
  636.         Rect    box;
  637.         Handle    item;
  638.         short    type;
  639.         
  640.         if (wDev & k50Percent)
  641.             disableAll = true;
  642.             
  643.         if (wDev & kSetResCalled)
  644.             disableAll = true;
  645.             
  646.         if (!(wDev & kPortrait))
  647.             disableDraft = true;
  648.         
  649.         // disable any controls we need to
  650.         for (idx = 6; idx <= 8; ++idx)
  651.             {
  652.             GetDItem((DialogPtr) *pDlg, idx, &type, &item, &box);
  653.             
  654.             if ( (disableAll) || ((disableDraft) && (idx == 8) ) )
  655.                 HiliteControl((ControlHandle) item, 255);
  656.             
  657.             }
  658.         }
  659.  
  660.     return(anErr);
  661.     
  662. } // SD_PrJobInit